${page.setTitle("push-center| GOPS")}
<div class="body-pla-content">
	<div class="s-table-wapper">
	<form action="">
		<table class="s-table">
			<tr>
			
				<td>
					消息内容：
				</td>
				<td>
					<input type="text" name="content"  id="content" value="${content!}"/>
				</td>
				<td>
					接受者id：
				</td>
				<td>
					<input type="text" name="receiveId"  id="receiveId" value="${receiveId!}"/>
				</td>
				<td><input id="btnSearch"  type="button" value="查询"  class="l-button"/>
				<input type="reset" value="清空" class="l-button l-button-reset"/> 
				</td>	
			</tr>
		</table>
		</form>
	</div>
	<div id="maingrid" style="margin:0; padding:0"></div>
	<div style="display:none;">
</div>



<script type="text/javascript">


var grid;
$(function () {
     var columns= [
       				{ display: 'ID', name: 'id', width: 100},
       				{ display: '生成时间', name: 'gmtCreated', width: 150,type:"datetime2"},
       				{ display: '修改时间', name: 'gmtModified', width: 150,type:"datetime2"},
       				{ display: '备注', name: 'memo'},
       				{ display: '接受者id', name: 'receiveId', width: 100},
       				{ display: '内容', name: 'content'},
       				{ display: '业务id', name: 'templateId', width: 100},
       				{ display: '发送时间', name: 'sendTime', width: 150,type:"datetime2"},
       				{ display: '状态', name: 'status', width: 100},
       				{ display: '获取次数', name: 'fetchCount', width: 100},
                   ];
       var toolbar={
				items: [
							 {text: '更新状态', click: toolbarBtnItemClick, icon:'refresh'},
							  { line:true }
						]
					 };	
	grid = $("#maingrid").ligerGrid({
						columns:columns,
						checkbox:false,
						enabledSort:false,
						pageSize:10,
						toolbar:toolbar,
						dataAction:'server',
						root:'rows',
						record :'total',
						pageParmName :'page',
						pagesizeParmName :'pageSize',
						width: '100%',
						height:'90%',
						url:'${appServer}/order/schedule/query.json',
						parms : $("form").serializeArray(),
						method:'get',
						onSuccess:function(data, grid){
							if(data.hasError){
								$.ligerDialog.error(data.message);
							}
						}
					});
     	
     $("#pageloading").hide();
     
      $("#btnSearch").click(function(){
		 search();
	 });
	 $("#resetTask").click(function(){
		 reset();
	 });
});

function reset(){
	$.ligerDialog.confirm('您确定要重置任务么？', function (yes)
                     {
                     	if(yes){
                         $.ajax({
              	        	url: "${appServer}/order/schedule/reset",   
              	        	type: "get",
              	        	success: function(result) {
              	        		if(result.hasError) {
              						$.ligerDialog.error(result.message);
              	        		}else{
              	        			$.ligerDialog.success(result.message);
              	        		
              	        		}
              	        	}
              	    	});
              	    	}
                   	});
}
function search(){
	 var appKey=$("#appKey");
 	 grid.setOptions( {
 		  		url: '${appServer}/order/schedule/query.json',
 		  		pageSize:10,
 		  		page:1,
 		  		content:'content',
 		  		recieveId:'receiveId',
 		  		dataAction:'server',
                parms : $("form").serializeArray()
         });
}



function toolbarBtnItemClick(item) {
	var url= null;
    switch (item.icon) {
        
        case "refresh":
            jQuery.ligerDialog.confirm('这个操作会把所有数据状态从入队成功置为入队失败,以便定时任务抓取数据重新发送。<br/>目的是为了使尚未发送成功由于服务器故障而没有发送的消息得以重新获得推送机会，<b>但是这样有可能造成消息重新推送。</b><br/>确定更新吗?', function (confirm) {
                if (confirm){
                	  $.ajax({
              	        url: "${appServer}/order/schedule/reset",   
              	        type: "get",
              	        success: function(result) {
              	        	if(result.hasError) {
              					$.ligerDialog.error(result.message);
              	        	}else{
              	        		$.ligerDialog.success(result.message);
              	        		window.search();
              	        	}
              	        }
              	    });
                 }
            });
            break;
    }
}


</script>
